const MusicModel = require("../models/MusicModel")



const MusicService = {
    add_music: async (data) => {
        return await MusicModel.create({
            ...data
        })
    },
    get_list: async (id) => {
        return {
            data: await MusicModel.find().select('-__v').limit(5).skip(id).sort({ publish_time: 'desc' }),
            count: await MusicModel.countDocuments()
        }
    },
    music_put: async (data) => {
        return await MusicModel.updateOne({
            _id: data._id
        }, {
            ...data
        })
    },
    music_delete: async (id) => {
        return await MusicModel.deleteOne({
            _id: id
        })
    }
}

module.exports = MusicService